/*
 * engine.h
 *
 *  Created on: 30.06.2011
 *      Author: marcell
 */

#ifndef __ENGINE_H__
#define __ENGINE_H__

#include <export.h>
#include <ifile.h>
#include <iwindow.h>
#include <sharedvaluemanager.h>

#include <gfx/idevice.h>
#include <gfx/ibillboardmesh.h>
#include <gfx/iinstancedmesh.h>
#include <gfx/imorphmesh.h>
#include <gfx/ipatchmesh.h>
#include <gfx/iskinmesh.h>
#include <gfx/istaticmesh.h>

class ceVFS;
class ceAssetSystem;
/**
 * \addtogroup engine
 * @{
 */

/**
 * @brief Central class that holds the CrimsonEngine together (well... it will).
 */
class CE_API ceEngine
{
  public:
    struct Config
    {
      bool      windowCreate;
      unsigned  windowWidth;
      unsigned  windowHeight;
      bool      windowFullscreen;
      iWindow*  window;
    };
  private:
    iDevice*			_device;

    iWindow*      _window;

    ceSharedValueManager* _sharedValueManager;

		std::string		_mediaPath;

		ceAssetSystem	*_assetSystem;

		void SetMediaPath(const std::string& path);
  public:
    ceEngine ();

		bool ReadCommandLineParams (int argc = 0, char** argv = 0);

    /**
     * @brief Initialize the engine
     *
     * When initializing the engine usualy a window is needed. You can specify via the config if the
     * engine should create a propper window or if a pre created window should be used.
     *
     * When the engine is used within a \a normal application there is only one window but when
     * the engine is used in a GUI application (an editor or something like this) there may be more
     * than one window. So there might not be \a one main window. You can specify \a overrideWindowpresence \a = \a 1
     * to tell the engine that no window should be created an no window is given via the config.
     * During rendering you must set the window via \a SetWindow() so that all parts of the engine
     * use a propper initialized windows.
     *
     * @param config Configuring the engine states
     * @param overrideWindowPresence If no window creation is specified and no window struct is given
     *        The initialization will fail, unless overrideWindowPresence is specified.
     *
     * @return \a True if the engine could be initialized else false.
     */
    bool Initialize (const Config& config, bool overrideWindowPresence = false);

    inline iDevice* GetDevice () const
    {
      return _device;
    }

    void SetWindow (iWindow *window) { _window = window; }

    inline iWindow* GetWindow () const
    {
      return _window;
    }

    inline ceSharedValueManager* GetSharedValueManager ()
    {
      return _sharedValueManager;
    }

		inline ceAssetSystem* GetAssetSystem ()
		{
			return _assetSystem;
		}


};

/** @} */

#endif /* ! __ENGINE_H__ */
